﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace UHFReaderDemo
{
        public partial class frm_LockData : Form
        {
                public delegate void SendCallback(String str);
                public event SendCallback send;

                public frm_LockData()
                {
                        InitializeComponent();
                }

                private void button1_Click(object sender, EventArgs e)
                {
                        chk1.Checked = true;
                        chk2.Checked = true;
                        chk11.Checked = true;
                        chk12.Checked = true;
                        chk3.Checked = true;
                        chk4.Checked = true;
                        chk13.Checked = true;
                        chk14.Checked = true;
                        chk5.Checked = true;
                        chk6.Checked = true;
                        chk15.Checked = true;
                        chk16.Checked = true;
                        chk7.Checked = true;
                        chk8.Checked = true;
                        chk17.Checked = true;
                        chk18.Checked = true;
                        chk9.Checked = true;
                        chk10.Checked = true;
                        chk19.Checked = true;
                        chk20.Checked = true;
                }

                private void button2_Click(object sender, EventArgs e)
                {
                        chk1.Checked = false;
                        chk2.Checked = false;
                        chk11.Checked = false;
                        chk12.Checked = false;
                        chk3.Checked = false;
                        chk4.Checked = false;
                        chk13.Checked = false;
                        chk14.Checked = false;
                        chk5.Checked = false;
                        chk6.Checked = false;
                        chk15.Checked = false;
                        chk16.Checked = false;
                        chk7.Checked = false;
                        chk8.Checked = false;
                        chk17.Checked = false;
                        chk18.Checked = false;
                        chk9.Checked = false;
                        chk10.Checked = false;
                        chk19.Checked = false;
                        chk20.Checked = false;
                }

                private void button4_Click(object sender, EventArgs e)
                {
                        this.Hide();
                }

                private void button3_Click(object sender, EventArgs e)
                {
                        Byte[] data = new Byte[3] { 0x00, 0x00, 0x00 };
                        if (chk1.Checked) data[0] |= 0x08;
                        if (chk2.Checked) data[0] |= 0x04;
                        if (chk3.Checked) data[0] |= 0x02;
                        if (chk4.Checked) data[0] |= 0x01;
                        if (chk5.Checked) data[1] |= 0x80;
                        if (chk6.Checked) data[1] |= 0x40;
                        if (chk7.Checked) data[1] |= 0x20;
                        if (chk8.Checked) data[1] |= 0x10;
                        if (chk9.Checked) data[1] |= 0x08;
                        if (chk10.Checked) data[1] |= 0x04;
                        if (chk11.Checked) data[1] |= 0x02;
                        if (chk12.Checked) data[1] |= 0x01;
                        if (chk13.Checked) data[2] |= 0x80;
                        if (chk14.Checked) data[2] |= 0x40;
                        if (chk15.Checked) data[2] |= 0x20;
                        if (chk16.Checked) data[2] |= 0x10;
                        if (chk17.Checked) data[2] |= 0x08;
                        if (chk18.Checked) data[2] |= 0x04;
                        if (chk19.Checked) data[2] |= 0x02;
                        if (chk20.Checked) data[2] |= 0x01;
                        String strData = String.Format("{0:X2}{1:X2}{2:X2}", data[0], data[1], data[2]);
                        send(strData);
                        this.Close();
                }

        }
}